package com.ketai.dao.impl;

import com.ketai.common.Result;
import com.ketai.dao.ApplicationDao;
import com.ketai.dao.BaseDao;
import com.ketai.pojo.Application;
import com.ketai.vo.ApplicationVo;

import javax.naming.NamingException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author:长沙科泰梦想学院-蓝色小药丸
 * @Mission:打造演说·创客型跨境电商与互联网人才
 * @Description:
 * @Date:Create In 2022/8/9 21:03
 **/
public class ApplicationDaoImpl extends BaseDao implements ApplicationDao {
    @Override
    public List<ApplicationVo> findAllApplication (String sql, Object[] param) throws SQLException, NamingException {
        ResultSet rs = query(sql, param);
        List<ApplicationVo> list = new ArrayList<ApplicationVo>();
        while (rs.next()) {
            ApplicationVo app = new ApplicationVo();
            app.setId(rs.getInt("id"));
            app.setSname(rs.getString("sname"));
            app.setPhone(rs.getString("phone"));
            app.setAchecked(rs.getInt("achecked"));
            app.setCheckedTime(rs.getDate("checkedTime"));
            app.setApplicationTime(rs.getDate("application_time"));
            app.setuName(rs.getString("uname"));
            app.setApply_time(rs.getDate("apply_time"));
            app.setDetail(rs.getString("detail"));
            list.add(app);
        }
        return list;
    }

    @Override
    public Long getApplicationCount (String sql, Object[] params) throws SQLException, NamingException {

        ResultSet rs = query(sql, params);
        long total = 0;
        while (rs.next()) {
            total = rs.getLong("total");
        }
        return total;
    }

    @Override
    public int checkedActity (String sql, Object[] params) throws SQLException, NamingException {
        int rs = curdMethod(sql, params);

        return rs;



    }
}
